import http from "../request";
const apibase = "/api/InventoryOrder";


/** 查询数据(盘点单) */
var getInventoryOrderList = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/GetInventoryOrderList`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};



/** 新增盘点单 */
var insInventoryOrder = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/InsInventoryOrder`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};




/** 修改盘点单 */
var updInventoryOrder = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/UpdInventoryOrder`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};



/** 删除盘点单 */
var delInventoryOrder = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/DelInventoryOrder`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};



/** 审核反审核盘点单 */
var reviewInventoryOrder = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/reviewInventoryOrder`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};


/** 下发盘点单 */
var issueInventoryOrder = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/IssueInventoryOrder`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};

/** 关闭盘点单 */

var closeInventoryOrder = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/CloseInventoryOrder`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};


/** 查询盘点单的盘点物料 */
var getInventoryCodeList = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/GetInventoryCodeList`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};


/** 新增盘点单的盘点物料 */
var insInventoryCode = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/InsInventoryCode`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};


/** 删除盘点单的盘点物料 */
var delInventoryCode = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/DelInventoryCode`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};



/** 完成盘点 */
var completeInventoryCode = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/CompleteInventoryCode`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};


/** 放弃盘点 */
var giveUpInventoryCode = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/GiveUpInventoryCode`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};


/** 添加盘点单明细 */
var getMaterialList = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/GetMaterialList`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};

/** 查询盘点单记录  */
var getInventoryRecordList = function (data) {
    return new Promise((resolve, reject) => {
        http
            .post(apibase + `/GetInventoryRecordList`, data)
            .then((res) => {
                resolve(res);
            })
            .catch((error) => {
                reject(error);
            });
    });
};







export {
    getInventoryOrderList,
    insInventoryOrder,
    updInventoryOrder,
    reviewInventoryOrder,
    issueInventoryOrder,
    getInventoryCodeList,
    insInventoryCode,
    delInventoryCode,
    completeInventoryCode,
    giveUpInventoryCode,
    closeInventoryOrder,
    delInventoryOrder,
    getMaterialList,
    getInventoryRecordList
};
